package com.qf.service.impl;

import com.qf.dao.AdminDao;
import com.qf.dao.impl.AdminDaoImpl;
import com.qf.domain.Goods;
import com.qf.domain.PageBean;
import com.qf.domain.User;
import com.qf.service.AdminService;

import java.util.List;

/**
 * @author YDW
 * projectName:shopping
 * time:2022/4/21 11:13
 * description:
 */
public class AdminServiceImpl implements AdminService {
    AdminDao adminDao=new AdminDaoImpl();
    @Override
    public User adminLogin(String username, String password) {
        return adminDao.selectByUsernameAndPassword(username,password);
    }

    @Override
    public List<User> getUserList() {
        return adminDao.findAllUser();
    }

    @Override
    public void delUser(String id) {
        adminDao.deleteUserById(id);
    }

    @Override
    public List<User> findByUsernameAndGender(String where, List<Object> params) {
        List<User> userList =adminDao.findByUsernameAndGender(where,params);
        return userList;
    }

    @Override
    public List<User> getinvalidUserList() {
        return adminDao.findAllinvalidUser();
    }

    @Override
    public void loseUser(String id) {
        adminDao.loseUser(id);
    }

    @Override
    public List<User> findinvalidUserByUsernameAndGender(String where, List<Object> params) {
        List<User> userList =adminDao.findinvalidUserByUsernameAndGender(where,params);
        return userList;
    }

    @Override
    public void activateUser(String id) {
        adminDao.activateUser(id);
    }

    @Override
    public PageBean findByPage(int pageNum, int pageSize) {
        Long UserCount=adminDao.findUserCount();
        List<User> data=adminDao.findData((pageNum-1)*pageSize,pageSize);
        PageBean pageBean=new PageBean(pageNum,UserCount,pageSize,data);
        return pageBean;
    }
}
